package com.fuershiye.woman.monitor.constants;


import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

public enum Years {

	YEAR_2010(2010, "2010"),
    YEAR_2011(2011, "2011"),
    YEAR_2012(2012, "2012"),
    YEAR_2013(2013, "2013"),
    YEAR_2014(2014, "2014"),
    YEAR_2015(2015, "2015"),
    YEAR_2016(2016, "2016"),
    YEAR_2017(2017, "2017"),
    YEAR_2018(2018, "2018"),
    YEAR_2019(2019, "2019"),
    YEAR_2020(2020, "2020");

    private final Integer code;
    private final String name;

    private static final Map<Integer,Years> lookupByCode=new HashMap<Integer, Years>();

    static {
        for(final Years p: EnumSet.allOf(Years.class)){
            lookupByCode.put(p.getCode(),p);
        }
    }


    Years(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }


    public static Years getPlatByCode(int code){
        return lookupByCode.get(code);
    }
    

    public static boolean contains(int plat) {
        for (Years p :values()){
            if (p.getCode()==plat){
                return true;
            }
        }
        return false;
    }

}
